//4단계 1번 리스트뷰 어댑터
package kr.jin.zeroprojectone;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyListAdapter extends BaseAdapter {
	Context mainContext;
	LayoutInflater Inflater;
	ArrayList<MyItems> arSrc;
	int layout;
	

	public MyListAdapter(Context mainContext, int layout, ArrayList<MyItems> arSrc) {
		super();
		this.mainContext = mainContext;
		this.Inflater = (LayoutInflater)mainContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.arSrc = arSrc;
		this.layout = layout;
	}

	@Override
	public int getCount() {
		return arSrc.size();
	}

	@Override
	public String getItem(int position) {
		return arSrc.get(position).activity;
	}
	
	public String getItem2(int position) {
		return arSrc.get(position).startTime;
	}
	
	public String getItem3(int position) {
		return arSrc.get(position).stopTime;
	}
	public String getItem4(int position) {
		return arSrc.get(position).between;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final int pos = position;
		if(convertView == null){
			convertView = Inflater.inflate(layout,parent,false);
		}

		TextView tvActivity = (TextView) convertView.findViewById(R.id.customlistview_tvActivity);
		tvActivity.setText(arSrc.get(position).activity);
		
		TextView tvStartTime = (TextView) convertView.findViewById(R.id.customlistview_tvStartTime);
		tvStartTime.setText(arSrc.get(position).startTime);
		
		TextView tvBetween = (TextView) convertView.findViewById(R.id.customlistview_tvBetweenTime);
		tvBetween.setText(arSrc.get(position).between);
		
		TextView tvStopTime = (TextView) convertView.findViewById(R.id.customlistview_tvStopTime);
		tvStopTime.setText(arSrc.get(position).stopTime);
		
		return convertView;
	}

}
